class Duchy < ActiveRecord::Base
  belongs_to  :kingdom
  has_many    :counties
  
  def Duchy.with_ruler(character)
    return nil unless character
    duchies = Duchy.find(:all)
    for duchy in duchies
      ruler = duchy.ruler
      return duchy unless ruler.nil? or ruler.id != character.id
    end
    return nil
  end
  
  def ruler
    Title.duke_of self
  end
end
